package com.idanchuang.component.logback;

import com.idanchuang.component.logback.config.*;
import com.idanchuang.component.logback.converter.MaskMessageConverter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yjy
 * @date 2019/12/31 15:14
 **/
@Configuration
public class ComponentLogbackAutoConfiguration {

    @Bean("componentLogbackCryptConfig")
    @ConfigurationProperties(prefix = "idanchuang.component.logback.crypt")
    public LogbackCryptConfig logbackCryptConfig() {
        return new LogbackCryptConfig();
    }

    @Bean("componentLogbackMaskConfig")
    @ConfigurationProperties(prefix = "idanchuang.component.logback.mask")
    public LogbackMaskConfig logbackMaskConfig() {
        return new LogbackMaskConfig();
    }

    @Bean("componentLogbackSentryConfig")
    @ConfigurationProperties(prefix = "idanchuang.component.logback.sentry")
    public LogbackSentryConfig logbackSentryConfig() {
        return new LogbackSentryConfig();
    }

    @Bean("componentLogbackSetMaskConfig")
    public Object componentLogbackSetMaskConfig(LogbackMaskConfig logbackMaskConfig) {
        MaskMessageConverter.setLogbackMaskConfig(logbackMaskConfig);
        return new Object();
    }

}
